package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;

@Entity
@Table(name = "web_child_item", schema = "web_mojianworld_server", catalog = "")
public class WebChildItem extends BaseForm {
  @Rules(id = true, min = "0")
  public int id;
  @Rules(min = "0")
  public int parentId;
  @Rules(fieldName = "二级分类")
  public String title;
  @Rules(fieldName = "图片URL", required = false)
  public String imgUrl;
  @Rules(fieldName = "展示优先级", required = false)
  public Integer orderNum;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "parentId", nullable = false)
  public int getParentId() {
    return parentId;
  }

  public void setParentId(int parentId) {
    this.parentId = parentId;
  }

  @Basic
  @Column(name = "title", nullable = false, length = 50)
  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  @Basic
  @Column(name = "imgUrl", nullable = true, length = 100)
  public String getImgUrl() {
    return imgUrl;
  }

  public void setImgUrl(String imgUrl) {
    this.imgUrl = imgUrl;
  }

  @Basic
  @Column(name = "orderNum", nullable = true)
  public Integer getOrderNum() {
    return orderNum;
  }

  public void setOrderNum(Integer orderNum) {
    this.orderNum = orderNum;
  }


  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + parentId;
    result = 31 * result + (title != null ? title.hashCode() : 0);
    result = 31 * result + (imgUrl != null ? imgUrl.hashCode() : 0);
    result = 31 * result + (orderNum != null ? orderNum.hashCode() : 0);
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
